#ifndef HIK_CAMERA_H
#define HIK_CAMERA_H

#include <iostream>
#include <string>
#ifdef _WIN32
#include <Windows.h>
#endif
#include "opencv2/core/core.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "CameraBase.h"
#include "HCNetSDK.h"
#ifdef _WIN32
#include "plaympeg4.h"
#elif __linux__
#include "PlayM4.h"
#endif

typedef struct
{
    float max;
    float min;
    float average;
} TEMPERATURE_INFO;

#ifdef DLL_EXPORT
class _declspec(dllexport) HikCamera : public CameraBase
#else
class HikCamera : public CameraBase
#endif
{
public:
    HikCamera();
    ~HikCamera();
#ifdef _WIN32
    int Init(HWND windowId, const char *IPAddress, int port, const char *userName, const char *password, int channel, int stream);
#elif __linux__
    int Init(unsigned int windowId, const char *IPAddress, int port, const char *userName, const char *password, int channel, int stream);
#endif
    void SetCallback(VideoDataCallback callback, void *context);
    void SetANPRInfoCallback(ANPRInfoCallback callback, void *context);
    int Connect();
    int Disconnect();
    int StartSaveVideo(const char *fileName);
    int StopSaveVideo();
    int GetTemperature(int ruleID, TEMPERATURE_INFO *temperature_info);

    VideoDataCallback callback = 0;
    ANPRInfoCallback anprInfoCallback = 0;
    void *context = 0;
    void *anprInfoCallbackContext = 0;

private:
    static bool InitSDK();
    static bool UninitSDK();

#ifdef _WIN32
    HWND windowId;
#elif __linux__
    unsigned int windowId;
#endif
    bool anprMode = false;
    std::string IPAddress;
    int port;
    std::string userName;
    std::string password;
    int channel;
    int stream;
    long realPlayHandle;
    int alarmHandle;
    int ruleID = 0;

protected:
    long userID;
};

#endif
